home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / DirectX / dxsdk_oct2004.exe / dxsdk.exe / Samples / C++ / Direct3D / SkinnedMesh / skinmesh2.vsh < prev    next >
Encoding:
Text File  |  2004-09-27  |  2.2 KB  |  92 lines

  1.  
  2. vs.1.1
  3.  
  4. ;------------------------------------------------------------------------------
  5. ; v0 = position
  6. ; v1 = blend weights
  7. ; v2 = blend indices
  8. ; v3 = normal
  9. ; v4 = texture coordinates
  10. ;------------------------------------------------------------------------------
  11.  
  12. ;------------------------------------------------------------------------------
  13. ; r0.w = Last blend weight
  14. ; r1 = Blend indices
  15. ; r2 = Temp position
  16. ; r3 = Temp normal
  17. ; r4 = Blended position in camera space
  18. ; r5 = Blended normal in camera space
  19. ;------------------------------------------------------------------------------
  20.  
  21. ;------------------------------------------------------------------------------
  22. ; Constants specified by the app;
  23. ;
  24. ; c9-c95 = world-view matrix palette
  25. ; c8      = diffuse * light.diffuse
  26. ; c7      = ambient color
  27. ; c2-c5   = projection matrix
  28. ; c1      = light direction
  29. ; c0      = {1, power, 0, 1020.01};
  30. ;------------------------------------------------------------------------------
  31.  
  32. ;------------------------------------------------------------------------------
  33. ; oPos      = Output position
  34. ; oD0      = Diffuse
  35. ; oD1      = Specular
  36. ; oT0      = texture coordinates
  37. ;------------------------------------------------------------------------------
  38.  
  39. dcl_position v0;
  40. dcl_blendweight v1;
  41. dcl_blendindices v2;
  42. dcl_normal v3;
  43. dcl_texcoord0 v4;
  44.  
  45. // Compensate for lack of UBYTE4 on Geforce3
  46. mul r1,v2.zyxw,c0.wwww
  47. //mul r1,v2,c0.wwww
  48.  
  49.  
  50. //first compute the last blending weight
  51. dp3 r0.w,v1.xyz,c0.xzz; 
  52. add r0.w,-r0.w,c0.x
  53.  
  54. //Set 1
  55. mov a0.x,r1.x
  56. m4x3 r4.xyz,v0,c[a0.x + 9];
  57. m3x3 r5.xyz,v3,c[a0.x + 9]; 
  58.  
  59. //blend them
  60. mul r4.xyz,r4.xyz,v1.xxxx
  61. mul r5.xyz,r5.xyz,v1.xxxx
  62.  
  63. //Set 2
  64. mov a0.x,r1.y
  65. m4x3 r2.xyz,v0,c[a0.x + 9];
  66. m3x3 r3.xyz,v3,c[a0.x + 9];
  67.  
  68. //add them in
  69. mad r4.xyz,r2.xyz,r0.wwww,r4;
  70. mad r5.xyz,r3.xyz,r0.wwww,r5;
  71.  
  72. //compute position
  73. mov r4.w,c0.x
  74. m4x4 oPos,r4,c2
  75.  
  76. // normalize normals
  77. dp3 r5.w, r5, r5;
  78. rsq r5.w, r5.w;
  79. mul r5, r5, r5.w;
  80.  
  81. ; Do the lighting calculation
  82. dp3 r1.x, r5, c1      ; normal dot light
  83. lit r1, r1
  84. mul r0, r1.y, c8      ; Multiply with diffuse
  85. add r0, r0, c7        ; Add in ambient
  86. min oD0, r0, c0.x     ; clamp if > 1
  87. mov oD1, c0.zzzz      ; output specular
  88.  
  89. ; Copy texture coordinate
  90. mov oT0, v4
  91.  
  92.